package com.bocloud.cmp.driver.convertor.os;

import java.util.List;

import org.openstack4j.model.network.Router;

import com.bocloud.cmp.driver.convertor.BeanConvert;
import com.bocloud.cmp.model.RouteModel;
import com.google.common.collect.Lists;

public class ConvertRoute implements BeanConvert<RouteModel, Router> {

	@Override
	public List<RouteModel> convertList(List<? extends Router> models) {
		List<RouteModel> routeModels = Lists.newArrayList();
		for (Router router : models) {
			routeModels.add(convertModel(router));
		}
		return routeModels;
	}

	@Override
	public RouteModel convertModel(Router model) {
		RouteModel routeMod = new RouteModel();
		routeMod.setAdminStateup(model.isAdminStateUp());
		routeMod.setStatus(model.getStatus().toString());
		if (null != model.getExternalGatewayInfo()) {
			routeMod.setNetworkId(model.getExternalGatewayInfo().getNetworkId());
			routeMod.setEnableSnat(model.getExternalGatewayInfo().isEnableSnat());
		}
		routeMod.setName(model.getName());
		routeMod.setRouteId(model.getId());
		routeMod.setTenantId(model.getTenantId());
		return routeMod;
	}

}
